using System;
using System.Collections.Generic;
using System.Text;

namespace MeshSimulation.EventManager
{
    class EventManager
    {
        SortedList<UInt64, Event> eventQueue = new SortedList<UInt64, Event>();
        
        public void addEvent(Event newEvent)
        {
            eventQueue.Add(newEvent.StartTime, newEvent);
        }

        public Event getNextEvent()
        {
            IEnumerator<KeyValuePair<UInt64, Event>> iterator = eventQueue.GetEnumerator();
           Event result = null;
           iterator.MoveNext();
           if (eventQueue.TryGetValue( iterator.Current.Key,out result))
               eventQueue.Remove(iterator.Current.Key);
           return result;
        }
    }
}
